/*
 * 版权所有 (C) 2015 知启蒙(ZHIQIM) 保留所有权利。[遇见知启蒙，邂逅框架梦]
 * 
 * https://zhiqim.org/project/zhiqim_framework/zhiqim_httpd.htm
 *
 * Zhiqim Httpd is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
package org.zhiqim.httpd.context.test;

import org.zhiqim.kernel.annotation.AnAlias;
import org.zhiqim.httpd.HttpRequest;
import org.zhiqim.httpd.context.annotation.AnIntercept;

/**
 * 知启蒙测试展示器，用于示例Ajax调用测试
 *
 * @version v1.4.1 @author zouzhigang 2018-12-12 新建与整理
 */
@AnAlias("ZmlTestPresenter")
public class ZmlTestPresenter
{
    public static void doTestSuccess(HttpRequest request)
    {
        request.setResponseResult("返回成功信息");
    }
    
    public static void doTestError(HttpRequest request)
    {
        request.setResponseResult(1, "返回[doTestError]错误码[1]");
    }
    
    public static void doTestException(HttpRequest request)throws Exception
    {
        throw new Exception("返回调用[doTestException]异常");
    }
    
    public static void doTestParam(HttpRequest request)
    {
        String p1 = request.getParameter("p1");
        String p2 = request.getParameter("p2");
        request.setResponseResult("返回[p1:"+p1+",p2:"+p2+"]");
    }
    
    public static void doTestParam(HttpRequest request, String p1, String p2)
    {
        System.out.println(p1);
        request.setResponseResult("返回[p1:"+p1+",p2:"+p2+"]");
    }
    
    @AnIntercept("ZmlErrorInterceptor")
    public static void doTestErrorInterceptor(HttpRequest request)
    {
        request.setResponseResult("返回成功信息");
    }

    @AnIntercept("ZmlRedirectInterceptor")
    public static void doTestRedirectInterceptor(HttpRequest request)
    {
        request.setResponseResult("返回成功信息");
    }
    
    public static void doTestLoading(HttpRequest request) throws InterruptedException
    {
        Thread.sleep(8 * 1000);
        request.setResponseResult("返回成功信息");
    }
}
